class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table "users", :force => true do |t|
      t.column :login,                     :string
      t.column :email,                     :string
      t.column :crypted_password,          :string, :limit => 40
      t.column :salt,                      :string, :limit => 40
      t.column :remember_token,            :string
      t.column :remember_token_expires_at, :datetime
      t.column :question,                  :text                        # 密码找回问题
      t.column :answer,                    :text                        # 密码找回答案
      t.column :avatar,                    :string                      # 用户头像
      t.column :points,                    :integer, :default => 0      # 商城积分
      t.column :coin,                      :integer, :default => 0      # 商城币
      t.column :money,                     :float, :default => 0        # 用户资金
      t.column :reg_time,                  :datetime                    # 注册时间
      t.column :last_login_time,           :datetime                    # 最后登陆时间
      t.column :last_ip,                   :string                      # 最后登陆ip
      t.column :email_check,               :boolean, :default => false  # 邮件确认
      t.column :email_check_code,          :string                      # 邮件确认码
      t.column :forgot_check_code,         :string                      # 密码找回码
      t.column :user_rank_id,              :integer, :default => 1      # 用户级别
      t.column :locked,                    :boolean, :default => false  # 用户锁定，1为锁定
      t.column :deleted_at, :datetime                                   # 删除时间
      t.timestamps
    end
    
    # 导入默认数据
    User.import_data
  end
  
  def self.down
    drop_table "users"
  end
end
